{
    class Players extends Laya.Box {
        constructor (data) {
            super();

            this.bg = null;
            this.light = null;
            this.tipBox = null;

            this.players = {};
            
            this.init(data);
        }

        destroy () {
            super.destroy();

            this.players = null;
            Sail.io.unregister("loading", this.update);
        }

        init (data) {
            this.size(GAME_CONFIG.WIDTH, 580);
            this.centerY = -15;
            this.addListItem(data);

            Sail.io.register("loading", this, this.update);
        }
        
        addListItem (data) {
            let mineSideIndex = -1;
            let mineSideSpliceIndex = -1;
            let teamMateData = null;
            let enemyData = null;

            for(let i = 0; i < data.length; i++){
                let _d = data[i];
                for(let j = 0; j < _d.length; j++){
                    if(_d[j].uid == GM.user_id){
                        mineSideIndex = i;
                        mineSideSpliceIndex = j;
                        break;
                    }
                }
            }

            teamMateData = data.splice(mineSideIndex, 1)[0];
            enemyData = data[0];

            teamMateData.splice(0, 0, teamMateData.splice(mineSideSpliceIndex, 1)[0]); //把自己的数据调整到第一条

            for(let i = 0; i < teamMateData.length; i++){
                let player = new Com.Loading.PlayerItem(i == 0 ? "mine" : "teammate");
                this.addChild(player);
                player.init(teamMateData[i], i);
                this.players[teamMateData[i].uid] = player;
            }

            for(let i = 0; i < enemyData.length; i++){
                let player = new Com.Loading.PlayerItem("enemy");
                this.addChild(player);
                player.init(enemyData[i], i);
                this.players[enemyData[i].uid] = player;
            }
        }

        update (data, code) {
            this.players[data.uid].update(data.p);
        }
    }

    Sail.class(Players, "Com.Loading.Players");
}